package adapter;

import voice.main.ChatFragment;
import voice.main.TextChatFragment;
import voice.main.VoiceChatFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class ChatAdapter extends FragmentPagerAdapter {  
	
    public ChatAdapter(FragmentManager fm) {  
        super(fm);  
    }  

    @Override  
    public Fragment getItem(int position) {   
        Fragment fragment = new ChatFragment();  
        switch (position) {  
        case 0:  
            return fragment = new TextChatFragment();  
        case 1:  
            return fragment = new VoiceChatFragment();  
        default:  
            break;  
        }  
        return fragment;
    }  

    @Override  
    public int getCount() {  
        return 2;  
    }  

    @Override  
    public CharSequence getPageTitle(int position) {   
        switch (position) {  
        case 0:  
            return "Chat By Text";  
        case 1:  
            return "Chat By Voice";  
        }  
        return null;  
    }  
}  

